//
//  StockSearchResultTableViewCell.m
//  RedManStock
//
//  Created by lanou3g on 15/7/31.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "StockSearchResultTableViewCell.h"
#import "DataHandle.h"
@implementation StockSearchResultTableViewCell

//重写setter方法

- (void)setStock:(SimpleStock *)stock{
    if (_stock!=stock) {
        _stock=stock;
    }
    self.stockNameLabel.text=stock.name;
    self.stockCodeLabel.text=stock.code;
    if (stock.collect==YES) {
        self.finishAddLabel.hidden=NO;
        self.addButton.hidden=YES;
        self.addButton.enabled=NO;
    }
    else if(stock.collect==NO){
        self.finishAddLabel.hidden=YES;
        self.addButton.hidden=NO;
        self.addButton.enabled=YES;
        [self.addButton addTarget:self action:@selector(addToMyStockList:) forControlEvents:UIControlEventTouchUpInside];
    }
    else{
        
    }
}

- (void)addToMyStockList:(UIButton *)button{
    self.finishAddLabel.hidden=NO;
    self.addButton.hidden=YES;
    self.addButton.enabled=NO;
    [[DataHandle shareHandle] changeMyStockWithStockCode:self.stock.code add:YES];
    self.cellBlock();
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
